package cn.cs.service;

import cn.cs.mapper.AppOrderMapper;
import cn.cs.pojo.*;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class RestAppOrderService {
    @Resource
    private AppOrderMapper appOrderMapper;
    @RequestMapping(value = "/getAppOrderById", method = RequestMethod.POST)
    @Transactional
    public AppOrder getAppOrderById(@RequestParam("appId")String appId) {
        return appOrderMapper.getAppOrderById(appId);
    }
    @RequestMapping(value = "/updateAppOrderState", method = RequestMethod.POST)
    @Transactional
    public int updateAppOrderState(Map<String, Object> map) {
       return   appOrderMapper.updateAppOrderState(map);
    }
    @RequestMapping(value = "/getParentFaultType", method = RequestMethod.POST)
    @Transactional
    public String getParentFaultType(@RequestParam("fault_category")String fault_category) {
        return appOrderMapper.getParentFaultType(fault_category);
    }
    @RequestMapping(value = "/getAllAppOrders", method = RequestMethod.POST)
    @Transactional
    List<AppOrder> getAllAppOrders(@RequestBody Map<String, Object> param){
        return appOrderMapper.getAllAppOrders(param);
    }
    @RequestMapping(value = "/getAllAfterOrders", method = RequestMethod.POST)
    @Transactional
    List<AfterOrder> getAllAfterOrders(@RequestParam("s") String s){
        return appOrderMapper.getAllAfterOrders(s);
    }
    @RequestMapping(value = "/updateAppOrder", method = RequestMethod.POST)
    @Transactional
    int updateAppOrder(@RequestBody AppOrder appOrder){
        return  appOrderMapper.updateAppOrder(appOrder);
    }

    @RequestMapping(value = "/getUserFullAddressByid", method = RequestMethod.POST)
    @Transactional
    String getUserFullAddressByid(@RequestParam("userAddressId") String userAddressId){
        return  appOrderMapper.getUserFullAddressByid(userAddressId);
    }



    @RequestMapping(value = "/getUserAddressListById", method = RequestMethod.POST)
    public List<UserAddress> getUserAddressListById(@RequestBody Map<String, Object> param)throws Exception{
        return appOrderMapper.getUserAddressListById(param);
    }

    @RequestMapping(value = "/getClientRepRelListByMap", method = RequestMethod.POST)
    public List<ClientRepRel> getClientRepRelListByMap(@RequestBody Map<String, Object> param)throws Exception{
        return appOrderMapper.getClientRepRelListByMap(param);
    }

    @RequestMapping(value = "/getAppOrderByAppOrderId", method = RequestMethod.POST)
    public Map<String,Object> getAppOrderByAppOrderId(@RequestParam("id") String id)throws Exception{
        return appOrderMapper.getAppOrderByAppOrderId(id);
    }

    @RequestMapping(value = "/getAppOrderCountByMap", method = RequestMethod.POST)
    public Integer getAppOrderCountByMap(@RequestBody Map<String, Object> param)throws Exception{
        return appOrderMapper.getAppOrderCountByMap(param);
    }

    @RequestMapping(value = "/itriptxAddAppOrder", method = RequestMethod.POST)
    public Integer itriptxAddAppOrder(@RequestBody AppOrder appOrder)throws Exception{
        return appOrderMapper.insertAppOrder(appOrder);
    }

    @RequestMapping(value = "/modifyAppOrder", method = RequestMethod.POST)
    public Integer modifyAppOrder(@RequestBody AppOrder appOrder)throws Exception{
        return appOrderMapper.updateAppOrder(appOrder);
    }

    @RequestMapping(value = "/getRepUserIdByAppOrderId", method = RequestMethod.POST)
    public Map<String, Object> getRepUserIdByAppOrderId(@RequestParam("id") String id)throws Exception{
        return appOrderMapper.getAppOrderByAppOrderId(id);
    }

    @RequestMapping(value = "/itriptxDeleteAppOrderById", method = RequestMethod.POST)
    public Integer itriptxDeleteAppOrderById(@RequestParam("id") Long id)throws Exception{
        return appOrderMapper.deleteAppOrderById(id);
    }

    @RequestMapping(value = "/getOverTimeAppOrderList", method = RequestMethod.POST)
    public List<Map<String, Object>> getOverTimeAppOrderList(){
        return appOrderMapper.getOverTimeAppOrderList();
    }

    @RequestMapping(value = "/getCourierServices", method = RequestMethod.POST)
    public List<Map<String, Object>> getCourierServices(){
        return appOrderMapper.getCourierServices();
    }

    @RequestMapping(value = "/saveCourierServices", method = RequestMethod.POST)
    public Integer saveCourierServices(@RequestParam("courierCompany") String courierCompany, @RequestParam("courierNumber") String courierNumber, @RequestParam("id") String id){
        return appOrderMapper.saveCourierServices(courierCompany, courierNumber, id);
    }


    @RequestMapping(value = "/insertUserAddress", method = RequestMethod.POST)
    public Integer insertUserAddress(@RequestBody UserAddress userAddress)throws Exception{
        return appOrderMapper.insertUserAddress(userAddress);
    }

    @RequestMapping(value = "/getRepairUserById", method = RequestMethod.POST)
    public RepairUser getRepairUserById(@RequestParam("id") Long id)throws Exception{
        return appOrderMapper.getRepairUserById(id);
    }

    @RequestMapping(value = "/getRepairUserAddressByAreaId", method = RequestMethod.POST)
    public Map<String, Object> getRepairUserAddressByAreaId(@RequestParam("repairUserId") String repairUserId, @RequestParam("area") String area)throws Exception{
        return appOrderMapper.getRepairUserAddressByAreaId(repairUserId, area);
    }

    @RequestMapping(value = "/updateClientUser", method = RequestMethod.POST)
    public Integer updateClientUser(@RequestBody ClientUser clientUser)throws Exception{
        return appOrderMapper.updateClientUser(clientUser);
    }

    @RequestMapping(value = "/getRepairUserByAreaId", method = RequestMethod.POST)
    public List<Map<String,Object>> getRepairUserByAreaId(@RequestParam("area") String area)throws Exception{
        return appOrderMapper.getRepairUserByAreaId(area);
    }

    @RequestMapping(value = "/toRepairOrder", method = RequestMethod.POST)
    public  void toRepairOrder(@RequestBody RepOrder repOrder) throws Exception{
        appOrderMapper.toRepairOrder(repOrder);
    }

    @RequestMapping(value = "/getAppOrderListByMap", method = RequestMethod.POST)
    public List<Map<String,Object>>	getAppOrderListByMap(@RequestBody Map<String, Object> param)throws Exception{
        return appOrderMapper.getAppOrderListByMap(param);
    }

    @RequestMapping(value = "/getAreaIdByOrderId", method = RequestMethod.POST)
    public Map<String,String>	getAreaIdByOrderId(@RequestParam("orderId") String orderId){
        return appOrderMapper.getAreaIdByOrderId(orderId);
    }

    @RequestMapping(value = "/getRepairUserDayByMap", method = RequestMethod.POST)
    public List<Map<String, Object>> getRepairUserDayByMap(@RequestBody Map<String, Object> param){
        return appOrderMapper.getRepairUserDayByMap(param);
    }

    @RequestMapping(value = "/getRepairUserDayByMapCount", method = RequestMethod.POST)
    public Integer getRepairUserDayByMapCount(@RequestBody Map<String, Object> param){
        return appOrderMapper.getRepairUserDayByMapCount(param);
    }

    @RequestMapping(value = "/userRepairApplyOrder", method = RequestMethod.POST)
    public Integer userRepairApplyOrder(@RequestBody AppOrder appOrder)throws Exception{
        return appOrderMapper.userRepairApplyOrder(appOrder);
    }



}
